package com.example.studentclass.controller;

import com.example.studentclass.entity.MyStudent;
import com.example.studentclass.service.MyStudentService;
import com.exmaple.result.ErrorCode;
import com.exmaple.result.Result;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping(value = "/studentclass")
public class MyStudentController {
    @Resource
    private MyStudentService myStudentService;

    @GetMapping("/all")
    public Result<List<MyStudent>> getAllStudentXML()
    {
        List<MyStudent> studentList = myStudentService.getAllStudentXML();
        return studentList.isEmpty()? Result.error(ErrorCode.USER_ERROR_A0201): Result.success(studentList);
    }
}
